home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / mmailp.idb / usr / lib / Zmail / bin / audiosend.z / audiosend
Encoding:
Text File  |  1997-01-22  |  2.8 KB  |  110 lines

  1. #!/bin/csh -fb
  2. # (The "-fb" might need to be changed to "-f" on some systems)
  3. #
  4. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  5. # Permission to use, copy, modify, and distribute this material 
  6. # for any purpose and without fee is hereby granted, provided 
  7. # that the above copyright notice and this permission notice 
  8. # appear in all copies, and that the name of Bellcore not be 
  9. # used in advertising or publicity pertaining to this 
  10. # material without the specific, prior written permission 
  11. # of an authorized representative of Bellcore.  BELLCORE 
  12. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  13. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  14. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  15. #
  16.  
  17. if (! $?METAMAIL_TMPDIR) then
  18.     set METAMAIL_TMPDIR=/tmp
  19. endif
  20.  
  21. # This is to make metamail/showaudio do playback on the speaker, not the phone.
  22. setenv AUDIOSPEAKERFORCE 1 
  23.  
  24. if (-d /usr/sony) then
  25.     set dev=/dev/sb0
  26. else
  27.     set dev=/dev/audio
  28. endif
  29.  
  30. if ( $#argv == 1 ) then
  31.     set to = $1
  32. else
  33.     echo -n "To: "
  34.     set to = $<
  35. endif
  36. echo -n "Subject: "
  37. set subject = $<
  38. echo -n "CC: "
  39. set cc = $<
  40.  
  41. record:
  42. echo -n "Press RETURN when you are ready to start recording: "
  43. set foo = $<
  44.  
  45. set fname = ${METAMAIL_TMPDIR}/a-out.$$
  46. set fnameraw = ${METAMAIL_TMPDIR}/a-raw.$$
  47.  
  48. echo "To: " "$to" > $fname
  49. echo "Subject: " "$subject" >> $fname
  50. echo "CC: " "$cc" >> $fname
  51. echo "MIME-Version: 1.0" >> $fname
  52. echo "Content-Type: audio/basic" >> $fname
  53. echo "Content-Transfer-Encoding: base64" >> $fname
  54. echo  "" >> $fname
  55. # THIS IS UNBELIEVABLY GRUBBY
  56. onintr cleanup
  57. if (! $?RECORD_AUDIO) then
  58.     (/bin/cat < $dev > $fnameraw) &
  59. else
  60.     ($RECORD_AUDIO > $fnameraw) &
  61. endif
  62. jobs -l > ${METAMAIL_TMPDIR}/AUDCAT.$$
  63. set foo=`/bin/cat ${METAMAIL_TMPDIR}/AUDCAT.$$`
  64. /bin/rm ${METAMAIL_TMPDIR}/AUDCAT.$$
  65. set PID=$foo[2]
  66. echo -n "press RETURN when you are done recording: "
  67. set foo=$<
  68. echo One moment please...
  69. /bin/sleep 1
  70. echo -n Killing recording job...
  71. /bin/kill -9 $PID >& /dev/null
  72. mimencode -b < $fnameraw >> $fname
  73. /bin/rm $fnameraw
  74. echo "" >> $fname
  75.  
  76. whatnext:
  77. echo ""
  78. echo "What do you want to do?"
  79. echo ""
  80. echo "1 -- Send mail"
  81. echo "2 -- Listen to recorded message"
  82. echo "3 -- Replace with a new recording"
  83. echo "4 -- Quit"
  84. set which = $<
  85.     switch ("$which")
  86.         case 1:
  87.           echo -n "Sending mail, please wait...  "
  88.           /usr/lib/sendmail $to  $cc < $fname
  89.           if (! $status) then
  90.             echo "Done."
  91.             rm $fname
  92.             exit
  93.           else
  94.             echo Mail delivery failed, draft mail is in $fname
  95.           endif
  96.           breaksw
  97.         case 2:
  98.           metamail -d $fname
  99.           breaksw
  100.         case 3:
  101.           goto record
  102.         case 4:
  103.           exit
  104.     endsw
  105. goto whatnext
  106. exit 0
  107. cleanup:
  108. kill -9 $PID >& /dev/null
  109.